Skip to content

Add Claude Code GitHub Workflow#5

Merged
aborruso merged 2 commits into
mainfrom
add-claude-github-actions-1769272491200
Jan 24, 2026
Merged

Add Claude Code GitHub Workflow#5
aborruso merged 2 commits into
mainfrom
add-claude-github-actions-1769272491200

Conversation

@aborruso

Copy link
Copy Markdown
Member

🤖 Installing Claude Code GitHub App

This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

What is Claude Code?

Claude Code is an AI coding agent that can help with:

  • Bug fixes and improvements
  • Documentation updates
  • Implementing new features
  • Code reviews and suggestions
  • Writing tests
  • And more!

How it works

Once this PR is merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.
Once the workflow is triggered, Claude will analyze the comment and surrounding context, and execute on the request in a GitHub action.

Important Notes

  • This workflow won't take effect until this PR is merged
  • @claude mentions won't work until after the merge is complete
  • The workflow runs automatically whenever Claude is mentioned in PR or issue comments
  • Claude gets access to the entire PR or issue context including files, diffs, and previous comments

Security

  • Our Anthropic API key is securely stored as a GitHub Actions secret
  • Only users with write access to the repository can trigger the workflow
  • All Claude runs are stored in the GitHub Actions run history
  • Claude's default tools are limited to reading/writing files and interacting with our repo by creating comments, branches, and commits.
  • We can add more allowed tools by adding them to the workflow file like:
allowed_tools: Bash(npm install),Bash(npm run build),Bash(npm run lint),Bash(npm run test)

There's more information in the Claude Code action repo.

After merging this PR, let's try mentioning @claude in a comment on any PR to get started!

Copilot AI review requested due to automatic review settings January 24, 2026 16:35
@aborruso
aborruso merged commit 2340bb6 into main Jan 24, 2026
5 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds GitHub Actions workflows to enable Claude Code integration for AI-assisted development tasks. The implementation includes two workflows: one for responding to @claude mentions in comments and another for automatic code reviews on pull requests.

Changes:

  • Added .github/workflows/claude.yml for interactive Claude mentions in PR/issue comments
  • Added .github/workflows/claude-code-review.yml for automatic PR code reviews

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 13 comments.

File Description
.github/workflows/claude.yml Workflow that triggers when @claude is mentioned in comments, allowing users to request AI assistance on PRs and issues
.github/workflows/claude-code-review.yml Automatic code review workflow that runs on PR events using Claude's code-review plugin

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow is missing write permissions that Claude Code Review may need to post its review comments. The code review tool needs to create PR comments to share its findings. However, the current permissions only grant 'read' access to contents, pull-requests, and issues.

To enable Claude to post review comments, consider adding:

  • pull-requests: write (for creating PR review comments)

Without write permission to pull requests, Claude will not be able to post its code review feedback.

Suggested change
pull-requests: read
pull-requests: write

Copilot uses AI. Check for mistakes.
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
runs-on: ubuntu-latest

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow lacks timeout protection, which could lead to excessive resource consumption if Claude gets stuck. GitHub Actions has a default maximum timeout of 6 hours for jobs, but it's better to set an explicit, reasonable timeout based on expected execution time.

Consider adding a timeout at the job level, for example:
timeout-minutes: 30

This ensures the workflow doesn't run indefinitely if something goes wrong.

Suggested change
runs-on: ubuntu-latest
runs-on: ubuntu-latest
timeout-minutes: 30

Copilot uses AI. Check for mistakes.
# github.event.pull_request.user.login == 'external-contributor' ||
# github.event.pull_request.user.login == 'new-developer' ||
# github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR'

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow lacks timeout protection, which could lead to excessive resource consumption if the code review process gets stuck. GitHub Actions has a default maximum timeout of 6 hours for jobs, but it's better to set an explicit, reasonable timeout based on expected execution time.

Consider adding a timeout at the job level, for example:
timeout-minutes: 30

This ensures the workflow doesn't run indefinitely if something goes wrong during the code review.

Suggested change
timeout-minutes: 30

Copilot uses AI. Check for mistakes.
# - "src/**/*.tsx"
# - "src/**/*.js"
# - "src/**/*.jsx"

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow lacks concurrency control, which could lead to multiple Claude Code Review instances running simultaneously on the same PR. This can cause race conditions, duplicate review comments, or wasted compute resources.

Consider adding a concurrency group to ensure only one code review workflow runs per PR at a time, for example:
concurrency:
group: claude-review-${{ github.event.pull_request.number }}
cancel-in-progress: true

This prevents multiple simultaneous code reviews on the same PR and saves resources by cancelling outdated reviews when new commits are pushed.

Suggested change
concurrency:
group: claude-review-${{ github.event.pull_request.number }}
cancel-in-progress: true

Copilot uses AI. Check for mistakes.
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 1

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shallow checkout with 'fetch-depth: 1' may be insufficient for Claude to properly understand the PR context. When Claude analyzes code changes, it may need access to more commit history to:

  • Understand the evolution of the code
  • Compare changes across multiple commits
  • See the full context of modifications

Consider either:

  1. Using 'fetch-depth: 0' to fetch full history (better context, slower checkout)
  2. Using a deeper fetch like 'fetch-depth: 10' (balanced approach)
  3. Or explicitly setting 'fetch-depth: 2' for PRs if only the immediate change needs review

The optimal value depends on how Claude Code uses the git history. Verify with the claude-code-action documentation what depth is recommended.

Suggested change
fetch-depth: 1
fetch-depth: 0

Copilot uses AI. Check for mistakes.
types: [opened, assigned]
pull_request_review:
types: [submitted]

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow lacks concurrency control, which could lead to multiple Claude instances running simultaneously on the same PR. This can cause race conditions, duplicate comments, or conflicting actions.

Consider adding a concurrency group to ensure only one Claude workflow runs per PR at a time, for example:
concurrency:
group: claude-${{ github.event.pull_request.number || github.event.issue.number }}
cancel-in-progress: true

This prevents multiple simultaneous executions on the same PR/issue.

Suggested change
concurrency:
group: claude-${{ github.event.pull_request.number || github.event.issue.number }}
cancel-in-progress: true

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +5
pull_request:
types: [opened, synchronize, ready_for_review, reopened]

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow runs on draft PRs, which may not be the desired behavior. The trigger includes 'opened', 'synchronize', and 'reopened' events without filtering out draft PRs, but also includes 'ready_for_review', suggesting draft PRs should be excluded.

Consider adding a condition to skip draft PRs:
if: github.event.pull_request.draft == false

This will prevent Claude from reviewing draft PRs that aren't ready for review, saving resources and avoiding premature feedback.

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +19
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a security concern: the PR description states "Only users with write access to the repository can trigger the workflow," but this is not enforced in the workflow configuration. The workflow triggers on 'issue_comment' and 'pull_request_review_comment' events without checking if the comment author has write access to the repository.

This means any user (including external contributors without write access) can trigger the workflow by mentioning @claude in a comment, potentially leading to:

  • Unauthorized use of the Anthropic API (consuming credits)
  • Spam or abuse of the Claude service
  • Denial of service by repeatedly triggering the workflow

Consider adding a permission check in the job condition:
if: |
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'

Note: This check would need to be adapted for each event type (issue_comment, pull_request_review_comment, etc.) since they have different data structures.

Suggested change
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
(
github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '@claude') &&
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
) ||
(
github.event_name == 'pull_request_review_comment' &&
contains(github.event.comment.body, '@claude') &&
(
github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR'
)
) ||
(
github.event_name == 'pull_request_review' &&
contains(github.event.review.body, '@claude') &&
(
github.event.review.author_association == 'OWNER' ||
github.event.review.author_association == 'MEMBER' ||
github.event.review.author_association == 'COLLABORATOR'
)
) ||
(
github.event_name == 'issues' &&
(
contains(github.event.issue.body, '@claude') ||
contains(github.event.issue.title, '@claude')
) &&
(
github.event.issue.author_association == 'OWNER' ||
github.event.issue.author_association == 'MEMBER' ||
github.event.issue.author_association == 'COLLABORATOR'
)
)

Copilot uses AI. Check for mistakes.

- name: Run Claude Code
id: claude
uses: anthropics/claude-code-action@v1

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow references the claude-code-action with a potentially unpinned version '@v1'. Using a major version tag means the workflow will automatically use the latest v1.x.x version, which could introduce breaking changes or unexpected behavior without notice.

For better security and reproducibility, consider:

  1. Pinning to a specific release (e.g., 'anthropics/claude-code-action@v1.0.0')
  2. Or using a commit SHA for maximum stability (e.g., 'anthropics/claude-code-action@abc123...')

This is especially important for workflows that can modify repository content and consume paid API credits. Verify the action's versioning strategy and choose an appropriate pinning approach.

Suggested change
uses: anthropics/claude-code-action@v1
uses: anthropics/claude-code-action@v1.0.0

Copilot uses AI. Check for mistakes.

- name: Run Claude Code Review
id: claude-review
uses: anthropics/claude-code-action@v1

Copilot AI Jan 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow references the claude-code-action with a potentially unpinned version '@v1'. Using a major version tag means the workflow will automatically use the latest v1.x.x version, which could introduce breaking changes or unexpected behavior without notice.

For better security and reproducibility, consider:

  1. Pinning to a specific release (e.g., 'anthropics/claude-code-action@v1.0.0')
  2. Or using a commit SHA for maximum stability (e.g., 'anthropics/claude-code-action@abc123...')

This is especially important for workflows that can modify repository content and consume paid API credits. Verify the action's versioning strategy and choose an appropriate pinning approach.

Suggested change
uses: anthropics/claude-code-action@v1
uses: anthropics/claude-code-action@v1.0.0

Copilot uses AI. Check for mistakes.
@aborruso
aborruso deleted the add-claude-github-actions-1769272491200 branch March 7, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants